package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.entity.Trashy;
import com.s3.khospitalds.service.TrashyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xw
 * @CreateTime: 2025/3/4
 * @Description: 药品浪费表
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class TrashyController {
    @Autowired
    private TrashyService trashyService;
    @GetMapping("/getAllTrashy")
    public R getAllTrashy() {
        return new R().addData("list",trashyService.selectAllTrashy());
    }
    @PostMapping("/updateTrashy")
    public R updateTrashy(@RequestBody Trashy trashy) {
        return new R().addData("update",trashyService.updateTrashy(trashy));
    }
    @PostMapping("/insertTrashy")
    public R insertTrashy(@RequestBody Trashy trashy) {
        return new R().addData("insert",trashyService.insertTrashy(trashy));
    }
    @PostMapping("/deleteTrashyById/{id}")
    public R deleteTrashyById(@RequestBody @PathVariable("id") Integer id) {
        return new R().addData("delete",trashyService.deleteTrashy(id));
    }
    @PostMapping("/deleteAllTrashy")
    public R deleteAllTrashy() {
        return new R().addData("deleteAll",trashyService.deleteAllTrashy());
    }
}
